package com.zhengjiang.sms.producer.config;

import com.zhengjiang.sms.common.Const;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName DirectRabbitConfig
 * @Description
 * @Author zhengjiang(99514925 @ qq.com)
 * @Date 2020-06-02 13:47
 * @Version V1.0
 **/
@Configuration
public class DirectRabbitConfig {

    @Bean
    public Queue smsDirectQueue(){
        return new Queue(Const.SMS_DIRECT_QUEUE,true);
    }

    @Bean
    DirectExchange smsDirectExchange(){
        return new DirectExchange(Const.SMS_DIRECT_EXCHANGE,true,false);
    }

    @Bean
    Binding bindingDirect(){
        return BindingBuilder.bind(smsDirectQueue()).to(smsDirectExchange()).with(Const.SMS_ROUTING_KEY);
    }

}
